/**
 * 购物车相关接口 
 */
var request = require('./request.js');
var utils = require('../utils/utils.js');

module.exports = {
  /**
   * 查询餐饮购物车
   */
  getCatering: function (storeId) {
    var params = {
      storeId: storeId
    }
    return request.get('/newretail/api/catering/shoppingCart/get', params)
  },
  cateringAdd: function (postData) {
    return request.post('/newretail/api/catering/shoppingCart/create', postData)
  },
  /**
   * 更新餐饮购物车
   * @param storeId 门店id
   * @param lists 商品id
   */
  update: function (postData) {
    return request.put('/newretail/api/catering/shoppingCart/update', postData)
  },
  /**
   * 批量删除购物车中的商品
   * @param shoppingItems 购物项id，多个购物项id以逗号分隔
   */
  remove: function (shoppingItems) {
    return request.delete('/newretail/api/catering/shoppingCart/remove?shoppingItems=' + shoppingItems)
  },
  /**
   * 查询购物车
   * @param storeId 门店id
   */
  get: function (storeId) {
    var params = {
      storeId: storeId
    }
    return request.get('/newretail/api/mall/product/shoppingcart/get', params)
  },
  /**
   * 添加商品进入购物车
   * @param storeId 门店id
   * @param lists 商品id
   */
  add: function (postData) {
    return request.post('/newretail/api/mall/product/shoppingcart/add', postData)
  },
  /**
   * 更新购物车
   * @param storeId 门店id
   * @param lists 商品id
   */
  sync: function (postData) {
    return request.post('/newretail/api/mall/product/shoppingcart/sync', postData)
  },
  /**
   * 批量删除购物车中的商品
   * @param productIds 商品id，多个商品id以逗号分隔
   */
  removeByProductIds: function (productIds) {
    return request.delete('/newretail/api/mall/product/shoppingcart/removeByProductIds?productIds=' + productIds)
  },

  /**
   * 查询用户购物车中的商品数量
   */
  getProductsCount: function () {
    return request.get('/newretail/api/mall/product/shoppingcart/getProductsCount')
  },
  /**
   * 根据商品计算促销金额
   */
  calcDiscount: function (postData) {
    return request.post('/newretail/api/promotion/calcDiscount', postData)
  },
}